package com.yet.kotlinapp.modules.login

import android.content.Context
import android.content.Intent
import com.yet.kotlinapp.entity.LoginResponseInfo
import com.yet.kotlinapp.modules.home.HomeActivity
import com.yet.kotlinapp.modules.login.inter.LoginPresenter
import com.yet.kotlinapp.modules.login.inter.LoginView
import com.yet.kotlinapp.modules.regist.RegisterActivity

/**
 *
 * @ProjectName: Kotlin app
 * @Package: com.yet.kotlinapp.modules.login.inter
 * @ClassName: LoginPresenterImp
 * @Description: java类作用描述
 * @Author: liys
 * @CreateDate: 2021/8/27 13:46
 * @UpdateUser: 更新者
 * @UpdateDate: 2021/8/27 13:46
 * @UpdateRemark: 更新说明
 * @Version: 1.0
 */
class LoginPresenterImp(var loginview:LoginView) :LoginPresenter,LoginPresenter.OnLoginActionListener{

    private val loginModel: LoginModelImp = LoginModelImp()

    override fun loginaction(
        context: Context,
        user: String,
        pw: String,
    ) {
        loginModel.login(user,pw,this);
    }
    fun toRegist(context: Context){
        var intent=Intent()
        intent.setClass(context,RegisterActivity::class.java)
        context.startActivity(intent)
    }

    fun toHome(context: Context,user: String){
        var intent=Intent()
        intent.putExtra("user",user)
        intent.setClass(context,HomeActivity::class.java)
        context.startActivity(intent)
    }

    override fun loginSuccess(logindata: LoginResponseInfo?) {
        loginview.loginSuccess(logindata)
    }

    override fun loginFail(msg: String?) {
        loginview.loginFialure(msg)
    }


}